﻿using System.Windows;
using System.Windows.Controls;
using Agnes.TaskManager;
using DevExpress.Xpf.Grid.TreeList;

namespace Agnes.TaskManager
{
    /// <summary>
    /// TaskSummaryView.xaml 的交互逻辑
    /// </summary>
    public partial class TaskSummaryView : UserControl
    {
        public TaskSummaryView()
        {
            InitializeComponent();
        }

        private void TaskCatagoryLoaded(object sender, RoutedEventArgs e)
        {
            ContentPresenter tb = sender as ContentPresenter;
            TreeListRowData o = tb.DataContext as TreeListRowData;
            if (o.Node.ParentNode != null)
            {
                o.Node.ParentNode.CollapseAll();
                o.Node.ParentNode.ExpandAll();
            }
        }
    }

    public class TaskDataTemplateSelector : DataTemplateSelector
    {
        public HierarchicalDataTemplate TaskSammaryDataTemplate { get; set; }

        public DataTemplate TaskDataTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (((item as TreeListRowData).Node.Content as Task).IsTaskCatagory)
            {
                return TaskSammaryDataTemplate;
            }
            else
            {
                return TaskDataTemplate;
            }


        }
    }

}